import request from '@/utils/request'
import type {
  TestTrendData,
  DimensionScoreData,
  AppointmentTrendData,
  CounselorWorkloadData,
  GeoDistributionData,
  IncomeStats,
  TimeRange,
  ConsultationTypeStats,
  CounselorIncomeData,
  ProblemTypeStats,
  CounselorIncomeParams
} from '../types/analysis'

// 获取测评趋势数据
export function getTestTrend(timeRange: TimeRange) {
  return request<TestTrendData>({
    url: '/analysis/test/trend',
    method: 'get',
    params: { timeRange }
  })
}

// 获取维度得分分布数据
export function getDimensionScore(testId: number) {
  return request<DimensionScoreData[]>({
    url: '/analysis/dimension/score',
    method: 'get',
    params: { testId }
  })
}

// 获取预约趋势数据
export function getAppointmentTrend(timeRange: TimeRange) {
  return request<AppointmentTrendData>({
    url: '/analysis/appointment/trend',
    method: 'get',
    params: { timeRange }
  })
}

// 获取咨询师工作量数据
export function getCounselorWorkload(timeRange: TimeRange) {
  return request<CounselorWorkloadData[]>({
    url: '/analysis/counselor/workload',
    method: 'get',
    params: { timeRange }
  })
}

// 获取平台收入趋势数据
export function getIncomeTrend(timeRange: TimeRange) {
  return request<IncomeStats>({
    url: '/analysis/income/trend',
    method: 'get',
    params: { timeRange }
  })
}

// 获取地理分布数据
export function getLoginGeoDistribution() {
  return request<GeoDistributionData[]>({
    url: '/analysis/login/geo',
    method: 'get'
  })
}

// 获取设备分布数据
export function getDeviceDistribution() {
  return request<GeoDistributionData[]>({
    url: '/analysis/device/distribution',
    method: 'get'
  })
}

// 获取咨询类型统计
export function getConsultationTypeStats() {
  return request<ConsultationTypeStats>({
    url: '/appointment/consultation-type-stats',
    method: 'get'
  })
}

// 获取问题类型分布
export function getProblemTypeDistribution() {
  return request<ProblemTypeStats>({
    url: '/record/problem-type-stats',
    method: 'get'
  })
}

// 获取咨询师收入数据
export function getCounselorIncome(params: CounselorIncomeParams) {
  return request<CounselorIncomeData[]>({
    url: '/analysis/counselor/income',
    method: 'get',
    params
  })
} 